<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        .container{
            width: 600px;
            margin: 0 auto;
            padding: 30px;
            background-color: #fed;
        }
        .price{
            font-size:25px;
            color:#f00;
            font-family: 'monaco';
            font-weight: 700;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>BTC 价格</h1>
        <hr>


        <ul id="btc">
            <li class="price"></li>
        </ul>


    </div>
    
    {js href="__JS__/jquery.min.js"}
    <script>
    $(function(){

        getAjax();

        setInterval(getAjax, 3000);




        function getAjax() {
            $.ajax({
                url: "{:url('index/Btc/getPrice')}",
                type: 'get',
                dataType: 'json',
                success: function(data) {
                    console.log(data);

                    $('#btc').empty();
                    for (var i in data) {
                       $('<li>', {
                        'class': 'price',
                        text: i + ':' + data[i].buy.toFixed(2) + data[i].symbol
                       }).appendTo('#btc');
                    }
                },
                error:function() {

                }
            });
        }
    });
    
    </script>
</body>
</html>